//
//  BillNotExistCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/6.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "BillNotExistCell.h"

@interface BillNotExistCell ()

@property (nonatomic, strong) UIImageView *headImage;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UILabel *moneyLabel;
@property (nonatomic, strong) UIButton *applyBtn;

@end

@implementation BillNotExistCell

- (void)setUnApplyBillModel:(UnApplyBillModel *)unApplyBillModel {
    [_headImage sd_setImageWithURL:[NSURL URLWithString:unApplyBillModel.goods_spic] placeholderImage:nil options:SDWebImageRetryFailed];
    _nameLabel.text = unApplyBillModel.goods_name;
    _moneyLabel.text = [NSString stringWithFormat:@"%@元",unApplyBillModel.total_fee];
}

+ (BillNotExistCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"BillNotExistCell";
    BillNotExistCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[BillNotExistCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    self.headImage = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(15), ScreenX375(140), ScreenX375(78))];
    self.headImage.layer.cornerRadius = ScreenX375(5);
    self.headImage.clipsToBounds = YES;
    self.headImage.image = [UIImage imageNamed:@"头部背景"];
    [self addSubview:self.headImage];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(163), ScreenX375(14), ScreenX375(150), ScreenX375(16))];
    self.nameLabel.text = @"纸箱纸板";
    self.nameLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.nameLabel.font = Kfont(14);
    [self addSubview:self.nameLabel];
    
    self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(113), ScreenX375(80), ScreenX375(100), ScreenX375(17))];
    self.moneyLabel.textColor = ThemeColor;
    self.moneyLabel.font = Kfont(12);
    self.moneyLabel.textAlignment = NSTextAlignmentRight;
    self.moneyLabel.text = @"100元";
    [self addSubview:self.moneyLabel];
    
    self.detailLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    self.detailLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.detailLabel.font = Kfont(12);
    [self addSubview:self.detailLabel];
    
    UIImageView *sLine = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(108), SCREEN_WIDTH - ScreenX375(26), 0.5)];
    sLine.image = [UIImage imageNamed:@"虚线"];
    [self addSubview:sLine];
    
    self.applyBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(268), ScreenX375(119), ScreenX375(94), ScreenX375(30))];
    self.applyBtn.layer.cornerRadius = ScreenX375(15);
    self.applyBtn.clipsToBounds = YES;
    self.applyBtn.layer.borderColor = ThemeColor.CGColor;
    self.applyBtn.layer.borderWidth = 0.5;
    [self.applyBtn setTitle:@"申请发票" forState:UIControlStateNormal];
    [self.applyBtn setTitleColor:ThemeColor forState:UIControlStateNormal];
    self.applyBtn.titleLabel.font = Kfont(14);
    [self.applyBtn addTarget:self action:@selector(applyClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.applyBtn];
}

- (void)applyClicked:(UIButton *)button {
    if (_applyClick) {
        _applyClick();
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation UnApplyBillModel

+(JSONKeyMapper*)keyMapper
{
    return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{
                                                                  @"Id": @"id",
                                                                  }];
}

@end
